/*
 * (C) Copyright 2023 orchy
 * This file is licensed under the BSD-3-Clause license.
 * <https://spdx.org/licenses/BSD-3-Clause.html>
 */
#ifndef _STDIO_H
#define _STDIO_H

#include <__stdarg.h>

// # 7.19.1
// ## 7.19.1.2
#ifndef _SIZE_T_DEFINED
  typedef long long int size_t;
  #define _SIZE_T_DEFINED
#endif
#include <__file.h>
typedef int fpos_t;

// ## 7.19.1.3
#ifndef NULL
  #define NULL ((void*)0)
#endif
#define _IOFBF (1)
#define _IOLBF (2)
#define _IONBF (3)
#define BUFSIZ (4096)
#define EOF (-1)
#define FOPEN_MAX (1024)
#define FILENAME_MAX (1024)
#define L_tmpnam (4096)
#define SEEK_CUR (1)
#define SEEK_END (2)
#define SEEK_SET (3)
#define TMP_MAX (1024)
#define stderr ((FILE*)0)
#define stdin ((FILE*)1024)
#define stdout ((FILE*)2048)

// # 7.19.4
// ## 7.19.4.1
int remove(const char* filename);

// ## 7.19.4.2
int rename(const char* old, const char* new);

// ## 7.19.4.3
FILE* tmpfile(void);

// ## 7.19.4.4
char* tmpnam(char* s);

// # 7.19.5
// ## 7.19.5.1
int fclose(FILE* stream);

// ## 7.19.5.2
int fflush(FILE* stream);

// ## 7.19.5.3
FILE* fopen(const char* restrict filename, const char* restrict mode);

// ## 7.19.5.4
FILE* freopen(const char* restrict filename, const char* restrict mode, FILE* restrict stream);

// ## 7.19.5.5
void setbuf(FILE* restrict stream, char* restrict buf);

// ## 7.19.5.6
int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size);

// # 7.19.6
// ## 7.19.6.1
int fprintf(FILE* restrict stream, const char* restrict format, ...);

// ## 7.19.6.2
int fscanf(FILE* restrict stream, const char* restrict format, ...);

// ## 7.19.6.3
int printf(const char* restrict format, ...);

// ## 7.19.6.4
int scanf(const char* restrict format, ...);

// ## 7.19.6.5
int snprintf(char* restrict s, size_t n, const char* restrict format, ...);

// ## 7.19.6.6
int sprintf(char* restrict s, const char* restrict format, ...);

// ## 7.19.6.7
int sscanf(const char* restrict s, const char* restrict format, ...);

// ## 7.19.6.8
int vfprintf(FILE* restrict stream, const char* restrict format, __va_list arg);

// ## 7.19.6.9
int vfscanf(FILE* restrict stream, const char* restrict format, __va_list arg);

// ## 7.19.6.10
int vprintf(const char* restrict format, __va_list arg);

// ## 7.19.6.11
int vscanf(const char* restrict format, __va_list arg);

// ## 7.19.6.12
int vsnprintf(char* restrict s, size_t n, const char* restrict format, __va_list arg);

// ## 7.19.6.13
int vsprintf(char* restrict s, const char* restrict format, __va_list arg);

// ## 7.19.6.14
int vsscanf(const char* restrict s, const char* restrict format, __va_list arg);

// # 7.19.7
// ## 7.19.7.1
int fgetc(FILE* stream);

// ## 7.19.7.2
char* fgets(char* restrict s, int n, FILE* restrict stream);

// ## 7.19.7.3
int fputc(int c, FILE* stream);

// ## 7.19.7.4
int fputs(const char* restrict s, FILE* restrict stream);

// ## 7.19.7.5
int getc(FILE* stream);

// ## 7.19.7.6
int getchar(void);

// ## 7.19.7.7
char* gets(char* s);

// ## 7.19.7.8
int putc(int c, FILE* stream);

// ## 7.19.7.9
int putchar(int c);

// ## 7.19.7.10
int puts(const char* s);

// ## 7.19.7.11
int ungetc(int c, FILE* stream);

// # 7.19.8
// ## 7.19.8.1
size_t fread(void* restrict ptr, size_t size, size_t nmemb, FILE* restrict stream);

// ## 7.19.8.2
size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb, FILE* restrict stream);

// # 7.19.9
// ## 7.19.9.1
int fgetpos(FILE* restrict stream, fpos_t* restrict pos);

// ## 7.19.9.2
int fseek(FILE* stream, long int offset, int whence);

// ## 7.19.9.3
int fsetpos(FILE* stream, const fpos_t* pos);

// ## 7.19.9.4
long int ftell(FILE* stream);

// ## 7.19.9.5
void rewind(FILE* stream);

// # 7.19.10
// ## 7.19.10.1
void clearerr(FILE* stream);

// ## 7.19.10.2
int feof(FILE* stream);

// ## 7.19.10.3
int ferror(FILE* stream);

// ## 7.19.10.4
void perror(const char* s);

#endif
